﻿@using CubicFWNet.Data.Models
@using CubicFWNet.Data.ViewModal
@model Worksheet
@{
    //ViewBag.Title = "加工单查看";
    var technology = ViewBag.Technology as Technology;
    //var orderProduct = ViewBag.OrderProduct as OrderProduct;
    var order = ViewBag.Order as Order;
    var product = ViewBag.Product as Product;
    var techType = ViewBag.TechType as TechType;
    var productTechnologyView = ViewBag.ProductTechnologyView as ProductTechnologyView;
    var equipments = ViewBag.Equipments as Equipment;
}
<section class="content-header">
    <h1>
        加工单查看
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("Query", "Worksheet")">加工单查询</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-solid">
        <!-- /.box-header -->
        <div class="box-body">
            <div class="row">
                @if (Model != null && product != null && technology != null && productTechnologyView != null && order != null)
                {
                    <form class="form-horizontal" id="frmedit" action="@Url.Action("UpdateCheckWorksheet", "Worksheet")" method="post">
                        <input type="hidden" id="Id" name="Id" value="@Model.Id" />
                        <input type="hidden" id="ApplyTime" name="ApplyTime" value="@Model.ApplyTime" />
                        <input type="hidden" id="Status" name="Status" value="@Model.Status" />

                        <input type="hidden" id="Ch" value="@technology.Ch" />@*//刀模数[左右]*@
                        <input type="hidden" id="Cv" value="@technology.Cv" />@*//刀模数[排]*@
                        <input type="hidden" id="Space" value="@technology.Space" />@*//左右间距-mm*@
                        <input type="hidden" id="Margin" value="@product.Margin">@*左右边距-mm*@
                        <input type="hidden" id="Distance" value="@product.Distance">@*跳距-mm*@

                        <input type="hidden" id="SizeWidth" value="@product.SizeWidth">@*尺寸宽-mm*@
                        <input type="hidden" id="SizeLenth" value="@product.SizeLenth">@*尺寸长-mm*@


                        <div class="box-body">
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">加工单编号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="Number" name="Number" value="@Model.Number" readonly="readonly" />
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">订单编号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="OrderNumber" name="OrderNumber" value="@order.Number" readonly="readonly" />
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">产品名称</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="ProductName" name="ProductName" value="@product.Name" readonly="readonly" />
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">生产数量</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="WorkAmount" name="WorkAmount" value="@Model.WorkAmount" readonly="readonly" />
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">合格数量</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="StandardAmount" name="StandardAmount" value="@Model.StandardAmount" readonly="readonly" />
                                </div>
                            </div>
                            @*<div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">版本</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="Edition" name="Edition" value="@Model.Edition" readonly="readonly" />
                                </div>
                            </div>*@
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div id="json-material">
                                <div class="form-group col-md-6">
                                    <label for="ProductName" class="col-sm-3 control-label">主原材料</label>
                                    <div class="col-sm-9" style="padding-top: 7px; margin-bottom: 0;">
                                        <a href="javascript:void(0)" class="productinfo" data-tid="@productTechnologyView.Id" data-mid="@productTechnologyView.ProductId">@productTechnologyView.ProductName</a>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label for="ProductName" class="col-sm-3 control-label">工艺详情</label>
                                    <div class="col-sm-9" style="padding-top: 7px; margin-bottom: 0;">
                                        <a href="javascript:void(0)" class="technologyinfo" data-tid="@productTechnologyView.Id" data-mid="@productTechnologyView.ProductId">【@productTechnologyView.ProductName】 工艺详情</a>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            @if (equipments != null)
                            {
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">设备</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="EquipmentType" name="EquipmentType" value="@equipments.EquipmentName" readonly="readonly" />
                                    </div>
                                </div>
                            }
                            @if (techType != null)
                            {
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">类别</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="TechType" name="TechType" value="@techType.TechTypeName" readonly="readonly" />
                                    </div>
                                </div>
                            }

                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <input type="hidden" id="workcontent" value="@Model.Data" readonly="readonly">
                            <div id="work-content">
                            </div>

                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">预计加工工时-分钟</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="ExpectedHours" name="ExpectedHours" value="@Model.ExpectedHours" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">实际加工工时-分钟</label>
                                <div class="col-sm-9">
                                    @if (Model.Status == 2)
                                    {
                                        <input type="text" class="form-control okeydown" id="ActualHours" name="ActualHours" value="">
                                    }
                                    else
                                    {
                                        <input type="text" class="form-control okeydown" id="ActualHours" name="ActualHours" value="@Model.ActualHours" readonly="readonly">
                                    }
                                </div>
                            </div>


                            <input type="hidden" id="hidLingData" name="hidLingData" value="@Model.LingData">
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">领料：</label>
                                <div class="col-sm-9">
                                    @if (Model.Status == 2)
                                    {
                                        <span class="btn btn-primary" id="showLing" style="margin-top: 5px;">添加行数</span>
                                    }
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div id="ling-content">
                                @if (Model.Status == 2)
                                {
                                    <div class="lingItem-content">
                                        <div class="form-group col-md-4">
                                            <label class="col-sm-3 control-label">长-m</label>
                                            <div class="col-sm-9">
                                                <input type="hidden" id="l_name" name="l_name" value="@product.Name">
                                                <input type="text" class="form-control okeydown" data-des='长-m' id="l_length" name="l_length" value="">
                                            </div>
                                        </div>
                                        <div class="form-group col-md-4">
                                            <label class="col-sm-3 control-label">宽-mm</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control okeydown" data-des='宽-mm' id="l_width" name="l_width" value="">
                                            </div>
                                        </div>
                                        <div class="form-group col-md-4">
                                            <label class="col-sm-3 control-label">数量</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control okeydown" data-des='数量' id="l_amount" name="l_amount" value="">
                                            </div>
                                        </div>
                                    </div>
                                }
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <input type="hidden" id="hidTuiData" name="hidTuiData" value="@Model.TuiData">
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">退料：</label>
                                <div class="col-sm-9">
                                    @if (Model.Status == 2)
                                    {
                                        <span class="btn btn-primary" id="showTui" style="margin-top: 5px;">添加行数</span>
                                    }
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div id="tui-content">
                                @if (Model.Status == 2)
                                {
                                    <div class="tuiItem-content">
                                        <div class="form-group col-md-4">
                                            <label class="col-sm-3 control-label">长-m</label>
                                            <div class="col-sm-9">
                                                <input type="hidden" id="l_name" name="l_name" value="@product.Name">
                                                <input type="text" class="form-control okeydown" data-des='长-m' id="l_length" name="l_length" value="">
                                            </div>
                                        </div>
                                        <div class="form-group col-md-4">
                                            <label class="col-sm-3 control-label">宽-mm</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control okeydown" data-des='宽-mm' id="l_width" name="l_width" value="">
                                            </div>
                                        </div>
                                        <div class="form-group col-md-4">
                                            <label class="col-sm-3 control-label">数量</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control okeydown" data-des='数量' id="l_amount" name="l_amount" value="">
                                            </div>
                                        </div>
                                    </div>
                                }

                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            @if (Model.Status == 2)
                            {
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">用料计算</label>
                                    <div class="col-sm-9">

                                        <span class="btn btn-primary" id="jisuanYongliao" style="margin-top: 5px;">计算</span>

                                    </div>
                                </div>
                                <div class="form-group col-md-12" style="height: 1px;"></div>
                            }

                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">预计用料 (㎡)</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="ExpectedMaterial" name="ExpectedMaterial" value="@Model.ExpectedMaterial" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">实际用料</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="ActualMaterial" name="ActualMaterial" value="@Model.ActualMaterial" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">用料公式</label>
                                <div class="col-sm-9">
                                    <label class="control-label" style="color: red">(领料面积-退料面积)/1000 ｛领料面积=长*宽*数量，退料面积一致｝</label>
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">备注</label>
                                <div class="col-sm-9">
                                    @if (Model.Status == 2)
                                    {
                                        <textarea class="form-control" rows="3" placeholder="请输入 ..." name="Memo" id="Memo">@Model.Memo</textarea>
                                    }
                                    else
                                    {
                                        <textarea class="form-control" rows="3" placeholder="请输入 ..." name="Memo" id="Memo" readonly="readonly">@Model.Memo</textarea>
                                    }
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">注意事项与工艺</label>
                                <div class="col-sm-9">
                                    <textarea class="form-control" rows="3" name="TechnologMemo" id="TechnologMemo" readonly="readonly">@Model.TechnologMemo</textarea>
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label for="operationName" class="col-sm-3 control-label">操作人</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationName" name="operationName" value="@Model.CreatorName" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="operationTime" class="col-sm-3 control-label">日期</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationTime" name="operationTime" value="@Model.CreateTime.Value.ToString("yyyy-MM-dd")" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="box-footer" style="width: 80%; margin-left: 20px;">
                            @if (Model.Status == 2)
                            {
                                <a role="button" href="javascript:void(0)" class="btn btn-primary submitbtn" onclick="formsubmit(2)">确认</a>
                            }
                            <span id="historyBack" class="btn btn-primary submitbtn">返回</span>
                            @*<a role="button" href="@Url.Action("Query", "Worksheet")" class="btn btn-primary">返回</a>*@
                        </div>
                    </form>
                }
            </div>
        </div>
    </div>
</section>

<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>

@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#frmedit").validate({
                submitHandler: function (form) {
                    var postData = $(form).formSerialize();
                    postData.Data = getParam();//JSON.stringify(postData._Data);
                    postData.LingData = getParamLing();
                    postData.TuiData = getParamTui();
                    $.submitForm({
                        url: $(form).attr("action"),
                        param: postData,
                        success: function () {
                            $.modalAlert("操作成功", "success");
                            window.location.href = '@Url.Action("Query", "Worksheet")';
                        }
                    });
                }
            });

            //var amount = $("#StandardAmount").val() / 1;//合格数量
            //var amount = $("#WorkAmount").val() / 1;//生产数量
            //calculate(amount);

            var sta = $("#Status").val();
            var read = "";
            if (sta == "3" || sta == "1") {//-1 初始化 1 提交  2 质检通过后  3:填写后来数据完成该生产单
                read = "readonly='readonly'";
            }

            var yy = document.getElementById("workcontent").value;
            if (yy != "") {
                var data1 = JSON.parse(document.getElementById("workcontent").value);//加工内容
                var $content1 = $('#work-content');
                var html1 = "";
                data1.forEach(function (e, i) {
                    if (typeof e.value == "undefined") {
                        e.value = "";
                    }
                    if (typeof e.name == "undefined") {
                        e.name = "";
                    }
                    if (typeof e.des == "undefined") {
                        e.des = "未知";
                    }
                    html1 += "<div class='form-group col-md-6'>";
                    html1 += "<label for='j_a' class='col-sm-3 control-label'>" + e.des + "</label>";
                    html1 += "<div class='col-sm-9'>";
                    html1 += "<input type='text' class='form-control' data-des='" + e.des + "' id='" + e.name + "' name='" + e.name + "' value='" + e.value + "' " + read + ">";
                    html1 += "</div></div>";
                });
                $content1.append(html1);
            }

            var yyling = document.getElementById("hidLingData").value;
            if (yyling != "") {
                var data = JSON.parse(document.getElementById("hidLingData").value);//领料内容
                var $content = $('#ling-content');
                var phtml = [];
                data.forEach(function (e, i) {
                    if (e.l_length != "0" && e.l_width != "0") {
                        phtml.push("<div class='lingItem-content'>");
                        phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>长</label>");
                        phtml.push("<div class='col-sm-9'><input type='hidden' id='l_name' name='l_name' value='" + e.l_name + "'><input type='text' class='form-control okeydown' data-des='长' id='l_length' name='l_length' value='" + e.l_length + "' " + read + "></div></div>");
                        phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>宽</label>");
                        phtml.push("<div class='col-sm-9'><input type='text' class='form-control okeydown' data-des='宽' id='l_width' name='l_width' value='" + e.l_width + "' " + read + "></div></div>");
                        phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>数量</label>");
                        phtml.push("<div class='col-sm-9'><input type='text' class='form-control okeydown' data-des='数量' id='l_amount' name='l_amount' value='" + e.l_amount + "' " + read + "></div></div>");
                        phtml.push("</div>");
                    }
                });
                $content.append(phtml.join(""));
            }

            var yytui = document.getElementById("hidTuiData").value;
            if (yytui != "") {
                var data2 = JSON.parse(document.getElementById("hidTuiData").value);//退料内容
                var $content2 = $('#tui-content');
                var phtml2 = [];
                data2.forEach(function (e, i) {
                    if (e.l_length != "0" && e.l_width != "0") {
                        phtml2.push("<div class='tuiItem-content'>");
                        phtml2.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>长</label>");
                        phtml2.push("<div class='col-sm-9'><input type='hidden' id='l_name' name='l_name' value='" + e.l_name + "'><input type='text' class='form-control okeydown' data-des='长' id='l_length' name='l_length' value='" + e.l_length + "' " + read + "></div></div>");
                        phtml2.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>宽</label>");
                        phtml2.push("<div class='col-sm-9'><input type='text' class='form-control okeydown' data-des='宽' id='l_width' name='l_width' value='" + e.l_width + "' " + read + "></div></div>");
                        phtml2.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>数量</label>");
                        phtml2.push("<div class='col-sm-9'><input type='text' class='form-control okeydown' data-des='数量' id='l_amount' name='l_amount' value='" + e.l_amount + "' " + read + "></div></div>");
                        phtml2.push("</div>");
                    }
                });
                $content2.append(phtml2.join(""));
            }
        });

        function formsubmit(t) {
            var actualMaterial = $("#ActualMaterial").val();
            if (isNaN(actualMaterial) || (actualMaterial / 1) == 0) {
                //$.modalAlert("请计算实际用料", "warning");
                //return false;
            }
            getParamLing();
            getParamTui();

            $("#frmedit").submit();
        }


        function getParam() {
            var postdata = [];
            //主键
            $("#work-content").find('input,select,textarea').each(function (r) {
                var $this = $(this);
                var id = $this.attr('id');
                var type = $this.attr('type');
                if (id) {
                    switch (type) {
                        case "checkbox":
                            postdata.push({ des: $this.attr("data-des"), name: id, value: $this.is(":checked") });
                            break;
                        case "select":
                            var value = $this.find("option:selected").val() == "" ? null : $this.find("option:selected").val();
                            postdata.push({ des: $this.attr("data-des"), name: id, value: value });
                            break;
                        default:
                            var value = $this.val() == "" ? "&nbsp;" : $this.val();
                            postdata.push({ des: $this.attr("data-des"), name: id, value: value });
                            break;
                    }
                }
            });
            return JSON.stringify(postdata);
        }


        //领料json
        function getParamLing() {
            var postdata = [];
            $("#ling-content").find('.lingItem-content').each(function (r, i) {
                var technologyItem = {};
                $(i).find('input').each(function (m) {
                    var $this = $(this);
                    var id = $this.attr('id');
                    var value = $this.val() == "" ? "0" : $this.val();
                    if (id) {
                        technologyItem[id] = value;
                    }
                });
                postdata.push(technologyItem);
            });
            console.log(postdata);
            return JSON.stringify(postdata);
        }
        //领料json
        function getParamTui() {
            var postdata = [];
            $("#tui-content").find('.tuiItem-content').each(function (r, i) {
                var technologyItem = {};
                $(i).find('input').each(function (m) {
                    var $this = $(this);
                    var id = $this.attr('id');
                    var value = $this.val() == "" ? "0" : $this.val();
                    if (id) {
                        technologyItem[id] = value;
                    }
                });
                postdata.push(technologyItem);
            });
            console.log(postdata);
            return JSON.stringify(postdata);
        }

        $("#historyBack").click(function () {
            window.history.go(-1);  //返回上一页
            //window.history.back();  //返回上一页
        });

        //领料添加行数
        $("#showLing").click(function () {
            var proName = $("#ProductName").val();
            var phtml = [];
            phtml.push("<div class='lingItem-content'>");
            phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>长-m</label>");
            phtml.push("<div class='col-sm-9'><input type='hidden' id='l_name' name='l_name' value='" + proName + "'><input type='text' class='form-control okeydown' data-des='长-m' id='l_length' name='l_length' value=''></div></div>");
            phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>宽-mm</label>");
            phtml.push("<div class='col-sm-9'><input type='text' class='form-control okeydown' data-des='宽-mm' id='l_width' name='l_width' value=''></div></div>");
            phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>数量</label>");
            phtml.push("<div class='col-sm-9'><input type='text' class='form-control okeydown' data-des='数量' id='l_amount' name='l_amount' value=''></div></div>");
            phtml.push("</div>");
            $("#ling-content").append(phtml.join(""));

        });

        //退料添加行数
        $("#showTui").click(function () {
            var proName = $("#ProductName").val();
            var phtml = [];
            phtml.push("<div class='tuiItem-content'>");
            phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>长-m</label>");
            phtml.push("<div class='col-sm-9'><input type='hidden' id='l_name' name='l_name' value='" + proName + "'><input type='text' class='form-control okeydown' data-des='长-m' id='l_length' name='l_length' value=''></div></div>");
            phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>宽-mm</label>");
            phtml.push("<div class='col-sm-9'><input type='text' class='form-control okeydown' data-des='宽-mm' id='l_width' name='l_width' value=''></div></div>");
            phtml.push("<div class='form-group col-md-4'><label class='col-sm-3 control-label'>数量</label>");
            phtml.push("<div class='col-sm-9'><input type='text' class='form-control okeydown' data-des='数量' id='l_amount' name='l_amount' value=''></div></div>");
            phtml.push("</div>");
            $("#tui-content").append(phtml.join(""));

        });

        //计算实际用料
        $("#jisuanYongliao").click(function () {
            var lingArea = 0;//领料总面积
            var tuiArea = 0;//退料总面积
            $("#ling-content").find('.lingItem-content').each(function (r, i) {
                var l = 0;//长
                var w = 0;//宽
                var c = 0;//数量
                var flag = false;
                $(i).find('input').each(function (m) {
                    var $this = $(this);
                    var id = $this.attr('id');
                    var value = 1;
                    if (id == "l_length") {
                        value = $this.val() == "" ? 0 : $this.val();
                        l = value / 1;
                    }
                    if (id == "l_width") {
                        value = $this.val() == "" ? 0 : $this.val();
                        w = value / 1;
                    }
                    if (id == "l_amount") {
                        value = $this.val() == "" ? 0 : $this.val();
                        c = value / 1;
                    }
                    if (value == 0 || value == "0" || isNaN(value)) {
                        flag = true;
                    }
                });
                if (flag) {
                    l = 0;//长
                    w = 0;//宽
                    c = 0;//数量
                }
                lingArea += l * w * c;
            });

            $("#tui-content").find('.tuiItem-content').each(function (r, i) {
                var l = 0;//长
                var w = 0;//宽
                var c = 0;//数量
                var flag = false;
                $(i).find('input').each(function (m) {
                    var $this = $(this);
                    var id = $this.attr('id');
                    var value = 1;
                    if (id == "l_length") {
                        value = $this.val() == "" ? 0 : $this.val();
                        l = value / 1;
                    }
                    if (id == "l_width") {
                        value = $this.val() == "" ? 0 : $this.val();
                        w = value / 1;
                    }
                    if (id == "l_amount") {
                        value = $this.val() == "" ? 0 : $this.val();
                        c = value / 1;
                    }
                    if (value == 0 || value == "0" || isNaN(value)) {
                        flag = true;
                    }
                });
                if (flag) {
                    l = 0;//长
                    w = 0;//宽
                    c = 0;//数量
                }
                tuiArea += l * w * c;
            });
            var actualMaterial = (lingArea - tuiArea) / 1000;
            $("#ActualMaterial").val(actualMaterial.toFixed(2));
        });


        function calculate(thisAmount) {
            var sizeWidth = $("#SizeWidth").val() / 1; //尺寸宽-mm
            var sizeLenth = $("#SizeLenth").val() / 1; //尺寸长-mm
            var ch = $("#Ch").val() / 1;//刀模数[左右]
            var cv = $("#Cv").val() / 1;//刀模数[排]
            var space = $("#Space").val() / 1; //左右间距-mm
            var margin = $("#Margin").val() / 1; //左右边距-mm
            var distance = $("#Distance").val() / 1; //跳距-mm

            var giveW = (sizeWidth * ch + (ch - 1) * space + margin * 2 * ch) / 1000;//给定用料宽-m(米)
            var comH = thisAmount / ch;
            var giveH = (sizeLenth + distance) * comH / 1000;//给定用料长-m(米)
            var area = giveW * giveH;
            $("#ExpectedMaterial").val(area.toFixed(2));

        }


        $(".okeydown").on("keydown", function () {
            var k = event.keyCode;
            if ((k <= 57 && k >= 48) || (k <= 105 && k >= 96) || (k == 8) || (k == 110) || (k == 190)) {
                return true;
            } else {
                return false;
            }
        });

        $(".technologyinfo").click(function () {
            var tid = $(this).data('tid');
            var mid = $(this).data('mid');
            var options = {
                id: null,
                title: '产品信息',
                width: "100%",
                height: "100%",
                url: "../Technology/TechnologyInfo?tId=" + tid + "&mId=" + mid,
                shade: 0.3,
                btn: ['返回'],
                btnclass: ['btn btn-danger'],
                callBack: null
            }
            $.modalOpen(options);
        });

        $(".productinfo").click(function () {
            var mid = $(this).data('mid');
            var options = {
                id: null,
                title: '产品信息',
                width: "100%",
                height: "100%",
                url: "../Product/Info?PID=" + mid,
                shade: 0.3,
                btn: ['返回'],
                btnclass: ['btn btn-danger'],
                callBack: null
            }
            $.modalOpen(options);
        });
    </script>
}